{% extends 'register/base.html' %}
{% load i18n %}
{% if wms %}
{% block script %}
<script src="/duetopia/register/static/OpenLayers.js"></script>
<script type="text/javascript">
	function init() {
		map = new OpenLayers.Map("preview",
			{ 'maxResolution': .28125, tileSize: new OpenLayers.Size(512, 512)});
		layer = new OpenLayers.Layer.WMS("{{layer.title}}",
			"{{wms.uri}}", { layers : "{{layer.name}}" });
		map.addLayer(layer);
		centroid = new OpenLayers.LonLat({{layer.extents.centroid.get_x}}, 
						 {{layer.extents.centroid.get_y}});
		map.setCenter(centroid, 0);
	}
</script>
{% endblock %}
{% endif %}
{% block tools %}
<a href="/duetopia/register/dataset/">{% trans "data sets" %}</a> |
<a href="/duetopia/register/layer/">{% trans "layers" %}</a> |
<!-- <a href="edit/">{% trans 'edit' %}</a> | -->
<a href="/duetopia/register/dataset/add/">{% trans "add" %} {% trans "data set" %}</a>
{% endblock %}
{% block content %}

<h2>{{layer.title}}</h2> 
<div id="metadata" class="metadata">

<table>
<tr><th>{% trans 'data set' %}</th>
    <td>{% if layer.dataset.name %}{{layer.dataset.name}}<br/>{% endif %}
        <a href="{{layer.dataset.get_absolute_url}}">{{layer.dataset}}</a></td></tr>
<tr><th>{% trans 'name' %}</th><td>{{layer.name}}</td></tr>
<tr><th>{% trans 'title' %}</th><td>{{layer.title}}</td></tr>
<tr><th>{% trans 'data sources' %}</th>
    <td><ul>
{% for source in layer.dataset.datasource_set.all %}
        <li>{{source.format.name}}<br/><a href="{{source.uri}}">{{source.uri}}</a></li>
{% endfor %}
    </ul></td></tr>
{% if layer.keywords.filter %}
<tr><th>{% trans 'keywords' %}</th>
    <td><ul>
{% for keyword in layer.keywords.all %}
        <li>{{keyword}}</li>
{% endfor %}
    </ul></td></tr>
{% endif %}
<tr><th>{% trans 'srid' %}</th>
    <td><ul>
{% for srs in layer.srs.all %}
        <li>{{srs.auth_name}}:{{srs.auth_srid}}</li>
{% endfor %}
    </ul></td></tr>
<tr><th>{% trans 'envelope' %}</th>
    <td><ul>
{% for polygon in layer.extents.envelope.tuple %}{% for point in polygon %}
        <li>{{point}}</li>
{% endfor %}{% endfor %}
    </ul></td></tr>
{% if layer.style_set.filter %}
<tr><th>{% trans 'styles' %}</th>
    <td><ul>
{% for style in layer.style_set.filter %}
        <li>{{style.title}}</li>
{% endfor %}
    </ul></td></tr>
{% endif %}
</table>
</div>
<div id="preview"></div>
{% endblock %}
